package 我的Java学习_算法基础.day_03;

import java.util.Arrays;
import java.util.Comparator;

public class _058_特殊排序 {
    public static void main(String[] args) {
        int res = f(new Integer[]{3,32,4,1});
        System.out.println(res);
    }
    private static int f(Integer[] arr){
        //自定义计较规则
        Arrays.sort(arr, new Comparator<Integer>(){
            @Override
            public int compare(Integer o1, Integer o2) {
                String s1 = o1+""+o2;
                String s2 = o2+""+o1;
                return s1.compareTo(s2);
            }
        });
        StringBuilder sb = new StringBuilder();
        for(int i =0;i<arr.length;i++){
            sb.append(arr[i]);
        }
        return Integer.parseInt(sb.toString());
    }
}
